import {defineConfig, loadEnv} from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from 'unplugin-vue-components/vite'
import {NaiveUiResolver} from 'unplugin-vue-components/resolvers'
import {resolve} from "path";

const config = loadEnv("development", "./");

export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            imports: [
                "vue",
                "vue-router",
                {
                    'naive-ui': ['useDialog', 'useMessage', 'useNotification', 'useLoadingBar'],
                },
            ],
            dts: "types/auto-import.d.ts",
        }),
        Components({
            resolvers: [NaiveUiResolver()]
        }),
    ],

    server: {
        host: "127.0.0.1",
        port: 3000,
        open: false,
        proxy: {
            "^/api": {
                target: `http://localhost:8000/`,
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ""),
            },
        },
    },

    resolve: {
        alias: {
            "@": resolve(__dirname, "./src"),
        },
    },
});
